package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.MoveBill;
import cn.wolfcode.crm.mapper.MoveBillMapper;
import cn.wolfcode.crm.query.QueryForObject;
import cn.wolfcode.crm.service.IMoveBillService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MoveBillServiceImpl implements IMoveBillService {

    @Autowired
    private MoveBillMapper moveBillMapper;

    public void insert(MoveBill moveBill) {
        moveBillMapper.insert(moveBill);
    }

    public MoveBill selectByPrimaryKey(Long id) {
        return moveBillMapper.selectByPrimaryKey(id);
    }

    public List<MoveBill> selectAll() {
        return moveBillMapper.selectAll();
    }

    public PageResult queryListByQo(QueryForObject qo) {
        int total = moveBillMapper.getTotalByQo(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<MoveBill> rows = moveBillMapper.getListByQo(qo);
        return new PageResult(total, rows);
    }
}
